<?php

/*------------------------------------------------
*
*   Explay Engine Content Management System.
*   Copyright © 2008 Golovdinov Alexander.
*
*-------------------------------------------------
*
*   Oficial site: wwww.alex-home.spb.ru/explay.html
*   Contact e-mail: golovdinov@gmail.com
*
*   GNU General Public License original source:
*   http://www.gnu.org/licenses/gpl-3.0.html
*
------------------------------------------------*/

if (!defined ('EXPLAY')) exit;


if ($_GET['mod'] == "clear_sessions") $db->query ("DELETE FROM ".DB_PEREFIX."_sessions");

if (isset($_GET['clear_cache'])) {
	if (clear_cache ())
		site_message ('Кеш очищен');
	else
		site_error ('Ошибка при очищении кеша');
}

$infofile = file ($_SERVER['DOCUMENT_ROOT'].'/engine/cmsinfo.txt');
$cmsinfo = array ();
foreach ($infofile as $s) {
	$s = explode ('=>', $s);
	$s[0] = trim ($s[0]);
	$s[1] = trim ($s[1]);
	$cmsinfo[$s[0]] = $s[1];
}

$last_update_time = (int) ($time = strtotime ($cmsinfo['lastupdate'])) ? $time : 0;
// Если обновление производилось больше недели назад, то выводим напоминание
if ((time () - $last_update_time) > 604800) cp_update_message ();

$mod_list = '';
$sys_list = '';
$ut_list = '';

$get = $db->query ("SELECT * FROM ".DB_PEREFIX."_admin_cp ORDER BY id");

while (list ($id, $group, $href, $name, $image) = $db->fetch_row ($get)) {
	
	$item = admincp_item ($id, $href, $name, $image);
	
	if ($group == 'modules')
		$mod_list .= $item;
	elseif ($group == 'system')
		$sys_list .= $item;
	else
		$ut_list .= $item;
	
}




function gdversion(){
    static $gd_version_number = null;
    if ($gd_version_number === null) {
        ob_start();
        phpinfo(8);
        $module_info = ob_get_contents();
        ob_end_clean();
        if (preg_match("/\bgd\s+version\b[^\d\n\r]+?([\d\.]+)/i",
                $module_info, $matches)) {
            $gdversion_h = $matches[1];
        } else {
            $gdversion_h = 0;
        } 
    } 
    return $gdversion_h;
} 

$information = "<table class=\"main_text\" cellspacing=\"0\" cellpadding=\"2\">
	<tr>
		<td width=\"250\">Web-сервер:</td>
		<td>".$_SERVER['SERVER_SOFTWARE']."</td>
	</tr>
	<tr>
		<td>Подпись сервера:</td>
		<td>".$_SERVER['SERVER_SIGNATURE']."</td>
	</tr>
	<tr>
		<td>Каталог на сервере:</td>
		<td>".$_SERVER['DOCUMENT_ROOT']."</td>
	</tr>
	<tr>
		<td>Версия PHP:</td>
		<td>".phpversion()."</td>
	</tr>
	<tr>
		<td>Версия MySQL:</td>
		<td>".mysql_get_server_info()."</td>
	</tr>
	<tr>
		<td>Версия GD:</td>
		<td>".gdversion()."</td>
	</tr>
	<tr>
		<td>Сборка Explay:</td>
		<td>".$cmsinfo['signature']."</td>
	</tr>
</table>";

work_table ($mod_list, $sys_list, $ut_list, $information);